ARG VERSION=latest

FROM codercom/code-server:${VERSION}

ENV SHELL /bin/bash

USER root

# 更新apt的资源列表、加速
# RUN sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
# RUN sudo sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list

RUN sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
RUN sudo sed -i "s@http://deb.debian.org@http://mirrors.163.com@g" /etc/apt/sources.list
RUN sudo apt-get update
RUN sudo apt install wget

# JDK
ARG JDK_VERSION=11
RUN sudo apt install -yqq openjdk-${JDK_VERSION}-jdk
# Java插件需要用到17+版本，这里额外去装一个版本。
RUN sudo apt install -yqq openjdk-17-jdk

# Node
ARG NODE_VERSION=16
RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION}.x | sudo -E bash -
RUN sudo apt install -y nodejs


ARG PHP_VERSION=7.4
RUN sudo apt-get install -yqq php${PHP_VERSION}


#安装Docker
RUN RUN curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
# RUN curl -sSL https://get.daoclo·ud.io/docker | sh

RUN sudo apt install -y python3-pip
RUN sudo pip install docker-compose -i https://pypi.tuna.tsinghua.edu.cn/simple

# Maven
RUN sudo apt-get install -y maven
VOLUME [ "/home/coder/.m2/repository/" ]

#网络工具包
RUN apt install -y net-tools
RUN apt install -y iproute2 
RUN apt install -y iputils-ping
 

# CodeServer配置文件
VOLUME ["/home/coder/.config/code-server/config.yaml"]

#Docker映射
VOLUME ["/var/run/docker.sock"]

#工作目录
RUN sudo mkdir /home/coder/project
VOLUME [ "/home/coder/project"]

COPY ./entry.sh /entry.sh

USER coder 

EXPOSE 8080

ENTRYPOINT ["code-server", "/entry.sh"]